<%--
 * list.jsp
 *
 * Copyright (C) 2013 Universidad de Sevilla
 * 
 * The use of this project is hereby constrained to the conditions of the 
 * TDG Licence, a copy of which you may download from 
 * http://www.tdg-seville.info/License.html
 --%>

<%@page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<%@taglib prefix="jstl" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="security"
	uri="http://www.springframework.org/security/tags"%>
<%@taglib prefix="display" uri="http://displaytag.sf.net"%>

<display:table pagesize="5" class="displaytag" keepStatus="true"
	name="events" requestURI="${requestURI}" id="row">


	<!-- Attributes -->

	<spring:message code="event.title" var="titleHeader" />
	<display:column property="title" title="${titleHeader}" sortable="${sortable}" />

	<spring:message code="event.start" var="startHeader" />
	<display:column property="startMoment" title="${startHeader}" sortable="${sortable}" />
	
	<spring:message code="event.finish" var="finishHeader" />
	<display:column property="finishMoment" title="${finishHeader}" sortable="${sortable}" />
	
	<spring:message code="event.description" var="descriptionHeader" />
	<display:column property="description" title="${descriptionHeader}" sortable="${sortable}" />
	
	<spring:message code="event.numberparticipants"
		var="numberparticipantsHeader" />
	<display:column title="${numberparticipantsHeader}" sortable="${sortable}">
		${row.registrations.size()}
	</display:column>
	
	<spring:message code="event.routes" var="routesHeader" />
	<display:column title="${routesHeader}" sortable="false">

		<a href="route/list.do?eventId=${row.id}"> <spring:message
				code="event.routes" />
		</a>
	</display:column>
	
	<spring:message code="event.challenges" var="challengesHeader" />
	<display:column title="${challengesHeader}" sortable="false">

		<a href="challenge/list.do?eventId=${row.id}"> <spring:message
				code="event.challenges" />
		</a>
	</display:column>
	
	<jstl:if test="${!sortable}">
	<spring:message code="event.rating" var="ratingHeader" />
	<display:column property="rating" title="${ratingHeader}" sortable="true" />
	</jstl:if>
	
	<security:authorize access="hasRole('PARTICIPANT')">
	<jstl:if test="${registrable}">
	<spring:message code="event.registration" var="registrationHeader" />
	<display:column title="${registrationHeader}" sortable="true">

		<a href="registration/participant/create.do?eventId=${row.id}"> <spring:message
				code="event.join" />
		</a>
	</display:column>
	</jstl:if>
	</security:authorize>
	
	<security:authorize access="hasRole('ADMIN')">
	<jstl:if test="${showDetails}">
	<spring:message code="event.details" var="detailsHeader" />
	<display:column title="${detailsHeader}" sortable="true">

		<a href="event/administrator/details.do?eventId=${row.id}"> <spring:message
				code="event.details" />
		</a>
	</display:column>
	</jstl:if>
	</security:authorize>
	
</display:table>

<!-- Action links -->
<security:authorize access="hasRole('ADMIN')">
	<jstl:if test="${showDetails}">
		<div>
			<a href="event/administrator/create.do"> <spring:message
					code="event.create" />
			</a>
		</div>
	</jstl:if>
</security:authorize>

